package cn.hchaojie.camp.day13;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.net.UnknownHostException;

public class Client {
	public static void main(String[] args) {
		// host:主机 port：端口
		try (
			Socket socket = new Socket("127.0.0.1", 6666);
			OutputStream os = socket.getOutputStream();
			InputStream in = socket.getInputStream();
				) {
			
			System.out.println("和服务器已经连上了。。。");
			
			// 通过socket和服务器通信
			os.write('A');
			
			System.out.println((char) in.read());
		} catch (UnknownHostException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
